//
//  TypeOrMagazineCell.m
//  YIJU2.0HD
//
//  Created by 张金国 on 16/5/17.
//  Copyright © 2016年 Mr.X. All rights reserved.
//

#import "TypeOrMagazineCell.h"
#import "Masonry.h"
#import "Macro.h"

#define kCellContentViewBackColor [UIColor colorWithRed:0.9451 green:0.9451 blue:0.9647 alpha:1.0].CGColor


@implementation TypeOrMagazineCell

#pragma mark - init
- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]){
        
        self.contentView.layer.borderWidth = 0.5f;
        self.contentView.layer.borderColor = kCellContentViewBackColor;
        
        [self setupConstraints];
    }
    return self;
}

#pragma mark - private
- (void)setupConstraints {
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.contentView);
        make.height.equalTo(@120);
    }];
    
    [self.barView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imageView.bottom);
        make.left.bottom.right.equalTo(self.contentView);
    }];
    
    [self.tagLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.equalTo(self.barView);
    }];
    
    [self.pushButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.bottom.equalTo(self.barView);
        make.width.equalTo(@40);
    }];
    
}

#pragma mark - getter
- (UIImageView *)imageView {
    if (!_imageView) {
        _imageView = [[UIImageView alloc]init];
        _imageView.contentMode = UIViewContentModeScaleAspectFit;
        _imageView.image = [UIImage imageNamed:@"ComputerType2"];
        [self.contentView addSubview:_imageView];
    }
    return _imageView;
}

- (UIView *)barView {
    if (!_barView) {
        _barView = [[UIView alloc]init];
        _barView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_barView];
    }
    return _barView;
}

- (UILabel *)tagLabel {
    if (!_tagLabel) {
        _tagLabel = [[UILabel alloc]init];
        _tagLabel.text = @"户型A";
        _tagLabel.textColor = kTextColor;
        [self.barView addSubview:_tagLabel];
    }
    return _tagLabel;
}

- (UIButton *)pushButton {
    if (!_pushButton) {
        _pushButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_pushButton setTitle:@"推送" forState:UIControlStateNormal];
        [_pushButton setTitleColor:[UIColor colorWithRed:0.9843 green:0.2706 blue:0.2392 alpha:1.0] forState:UIControlStateNormal];
        [self.barView addSubview:_pushButton];
    }
    return _pushButton;
}


@end
